home *** CD-ROM | disk | FTP | other *** search
/ Cre@te Online 2000 December / Cre@teOnline CD05.iso / MacSoft / XML ConsoleMax.sea / XML ConsoleMax / Required / parser.jar / com / sun / xml / parser / DocumentBuilderImpl.class (.txt) < prev    next >
Encoding:
Java Class File  |  2000-02-23  |  2.2 KB  |  83 lines

  1. package com.sun.xml.parser;
  2.  
  3. import com.sun.xml.tree.XmlDocument;
  4. import com.sun.xml.tree.XmlDocumentBuilder;
  5. import java.io.IOException;
  6. import javax.xml.parsers.DocumentBuilder;
  7. import javax.xml.parsers.DocumentBuilderFactory;
  8. import org.w3c.dom.Document;
  9. import org.xml.sax.EntityResolver;
  10. import org.xml.sax.ErrorHandler;
  11. import org.xml.sax.InputSource;
  12. import org.xml.sax.SAXException;
  13.  
  14. public class DocumentBuilderImpl extends DocumentBuilder {
  15.    private DocumentBuilderFactory dbf;
  16.    // $FF: renamed from: er org.xml.sax.EntityResolver
  17.    private EntityResolver field_0 = null;
  18.    // $FF: renamed from: eh org.xml.sax.ErrorHandler
  19.    private ErrorHandler field_1 = null;
  20.    private Parser parser = null;
  21.    private XmlDocumentBuilder builder = null;
  22.    private boolean namespaceAware = false;
  23.    private boolean validating = false;
  24.  
  25.    DocumentBuilderImpl(DocumentBuilderFactory var1) {
  26.       this.dbf = var1;
  27.       this.builder = new XmlDocumentBuilder();
  28.       if (var1.isValidating()) {
  29.          this.parser = new ValidatingParser();
  30.          this.validating = true;
  31.       } else {
  32.          this.parser = new Parser();
  33.       }
  34.  
  35.       if (var1.isNamespaceAware()) {
  36.          this.builder.setDisableNamespaces(false);
  37.          this.namespaceAware = true;
  38.       }
  39.  
  40.       this.builder.setParser(this.parser);
  41.       this.parser.setDocumentHandler(this.builder);
  42.    }
  43.  
  44.    public boolean isNamespaceAware() {
  45.       return this.namespaceAware;
  46.    }
  47.  
  48.    public boolean isValidating() {
  49.       return this.validating;
  50.    }
  51.  
  52.    public Document newDocument() {
  53.       return new XmlDocument();
  54.    }
  55.  
  56.    public Document parse(InputSource var1) throws SAXException, IOException {
  57.       if (var1 == null) {
  58.          throw new IllegalArgumentException("InputSource cannot be null");
  59.       } else {
  60.          if (this.field_0 != null) {
  61.             this.parser.setEntityResolver(this.field_0);
  62.          } else {
  63.             this.parser.setEntityResolver(new Resolver());
  64.          }
  65.  
  66.          if (this.field_1 != null) {
  67.             this.parser.setErrorHandler(this.field_1);
  68.          }
  69.  
  70.          this.parser.parse(var1);
  71.          return this.builder.getDocument();
  72.       }
  73.    }
  74.  
  75.    public void setEntityResolver(EntityResolver var1) {
  76.       this.field_0 = var1;
  77.    }
  78.  
  79.    public void setErrorHandler(ErrorHandler var1) {
  80.       this.field_1 = var1;
  81.    }
  82. }
  83.